package team.knowers.qzh.qzhserver.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import team.knowers.qzh.qzhserver.common.convention.result.Result;
import team.knowers.qzh.qzhserver.common.convention.result.Results;
import team.knowers.qzh.qzhserver.dto.resp.ChapterDetailsRespDTO;
import team.knowers.qzh.qzhserver.service.ChapterService;

import java.util.List;

/**
 * 单元控制层
 */

@RestController
@RequiredArgsConstructor
public class ChapterController {
    private final ChapterService chapterService;

    /**
     * 展示课程单元详情页
     */
    @GetMapping("/api/qzh-server/admin/v1/chapter/details/{courseId}")
    public Result<List<ChapterDetailsRespDTO>> getChapterDetailsById(@PathVariable("courseId") Long id) {
        return Results.success(chapterService.getChapterDetailsById(id));
    }
}
